import { useLanguageStore } from '@/stores/language'
import { appox } from '@/appox/appox'
import { biBridge } from '@/appox/bi-bridge'

// 打印版本信息
export const printVersionText = () => {
    const languageStore = useLanguageStore()
    appox.print((languageStore.isChinese ? "版本: " : "Versions: ") + 
        "appox.js (" + appox.getVersion() + "), bi-bridge.js (" + biBridge.getVersion() + ")")
}

// 初始化颜色主题
export let isDark = false
export const initializeColorTheme = () => {

    isDark = window.matchMedia('(prefers-color-scheme: dark)').matches
    document.documentElement.setAttribute('data-bs-theme', isDark ? 'dark' : 'light')
    if (isDark) {
        document.documentElement.classList.add('dark')
    } else {
        document.documentElement.classList.remove('dark')
    }

    window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => {
        isDark = e.matches
        document.documentElement.setAttribute('data-bs-theme', isDark ? 'dark' : 'light')
        if (isDark) {
            document.documentElement.classList.add('dark')
        } else {
            document.documentElement.classList.remove('dark')
        }
    })
}